package com.dsl.dslallinone.dto;

/**
 * 指标类型枚举
 */
public enum MetricType {
    SUM("sum", "求和"),
    AVG("avg", "平均值"),
    MAX("max", "最大值"),
    MIN("min", "最小值"),
    COUNT("count", "计数"),
    DISTINCT_COUNT("distinct_count", "去重计数"),
    CUMULATIVE("cumulative", "累计值"),
    RATE("rate", "比率"),
    MOVING_AVG("moving_avg", "移动平均"),
    ROLLING_SUM("rolling_sum", "滚动求和"),
    YOY("yoy", "同比"),
    MOM("mom", "环比"),
    GROWTH_RATE("growth_rate", "增长率"),
    PCT_OF_TOTAL("pct_of_total", "占比"),
    TOP_N("topN", "TopN"),
    RANK("rank", "排名"),
    FILL_MISSING("fill_missing", "缺失值填充"),
    RESAMPLE("resample", "重采样"),
    COP("cop", "性能系数"),
    EER("eer", "能效比"),
    NORMALIZE_BY_AREA("normalize_by_area", "按面积标准化"),
    PER_CAPITA("per_capita", "人均");

    private final String code;
    private final String desc;

    MetricType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static MetricType fromCode(String code) {
        for (MetricType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown metric type code: " + code);
    }
}
